package com.ciwong.epaper.modules.viedoexplantion.imp;

import android.content.Context;
import android.graphics.Color;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.text.style.UnderlineSpan;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.ciwong.epaper.R;
import com.ciwong.epaper.modules.viedoexplantion.LoadUi;
import com.ciwong.libs.utils.CWLog;

/**
 * Created by young on 2016/7/5.
 * 写作题类布局加载类
 */
public class WriteLoadUi implements LoadUi {

    private TextView tv_composition_title;
    private  TextView tv_composition_answer;
    private SpannableString msp = null;

    @Override
    public View loadLayout(Object  o, Context context,Boolean b) {

        View view= LayoutInflater.from(context).inflate(R.layout.item_composition_writing,null);

        tv_composition_title = (TextView) view.findViewById(R.id.tv_composition_title);

        tv_composition_answer = (TextView) view.findViewById(R.id.tv_composition_answer);

        tv_composition_title.setText("你所在的城市即将举办国际贸易博览会。有关部门现向全社会招聘志愿者。要求：\n" +
                "(1)具有为国际友人服务的热情；\n" +
                "(2)掌握丰富的文化知识，既是服务人员，也是文化的使者；\n" +
                "(3)具有流利的英语表达能力，能做好沟通工作。\n" +
                "假如你叫李华，请根据以上要求，写一封想作博览会志愿者的申请信。\n" +
                "要求：字迹工整，100词左右。开头已写好，不计入总词数。\n" +
                "生词：国际贸易博览会 the International Trade Exposition");
        displayAnswer( );
        return view;

    }




    private  void  displayAnswer( )
    {
        String answerStr="   Thank you for taking your time to read my letter. As the coming of the International Trade Exposition, I’d like very much to be a volunteer。\n" +
                "All our citizens are hosts for this special event. Above all, I promise I should endeavor to serve with enthusiasm our distinguished guests from all over the world. Besides, I have a rich knowledge about Chinese history, so I will be not only a servant but also a carrier for our splendid culture. What’s more, as we all know, English as an international language, will play an important role in communication during the Exposition, " +
                "and I am good at it. I can express myself fluently and clearly in English。";
        msp = new SpannableString(answerStr);
        msp.setSpan(new UnderlineSpan( ), 0, answerStr.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        msp.setSpan(new ForegroundColorSpan(Color.RED),  0, answerStr.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        tv_composition_answer.setText(msp);

        CWLog.d("ciwong", "#####tv_composition_answer.getLineCount()#######"+tv_composition_answer.getLineCount());
        CWLog.d("ciwong", "#####tv_composition_answer.getHeight()#######"+tv_composition_answer.getHeight());


    }


}
